<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 移动所有球到每个盒子所需的最小操作数 -->
    <script>
      function minOperations(boxes) {
        let ans = new Array(boxes.length).fill(0)
        for (let i = 0; i < ans.length; i++) {
          for (let j = 0; j < boxes.length; j++) {
            if (boxes[j] === '1') ans[i] += Math.abs(i - j)
          }
        }
        return ans
      }
      console.log(minOperations('110'))
    </script>
  </body>
</html>
